package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.CustomRules;
import com.example.demo.service.CustomRulesService;
import com.example.demo.mapper.CustomRulesMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 18364
* @description 针对表【custom_rules】的数据库操作Service实现
* @createDate 2025-04-16 13:44:36
*/
@Service
public class CustomRulesServiceImpl extends ServiceImpl<CustomRulesMapper, CustomRules>
    implements CustomRulesService{
    @Autowired
    CustomRulesMapper customRulesMapper;

    @Override
    public List<CustomRules> select(String userId, String appId, String trainingId) {
        QueryWrapper<CustomRules> queryWrapper=new QueryWrapper<>();
        if(userId!=null){
            queryWrapper.eq("userId",userId);
        }
        if(appId!=null){
            queryWrapper.eq("appId",appId);
        }
        if(trainingId!=null){
            queryWrapper.eq("trainingId",trainingId);
        }
        queryWrapper.orderByDesc("id");
        return customRulesMapper.selectList(queryWrapper);
    }

    @Override
    public CustomRules selectById(Integer id) {

        return customRulesMapper.selectById(id);
    }
}




